import { request } from '@/plugin/request'

// 用户登录
export function loginData (cellphone, password) {
  return request({
    url: 'home/user/pwdlogin',
    method: 'post',
    data: {
      cellphone,
      password
    }
  })
}

// 退出登录
export function safeout (uid) {
  return request({
    url: '/home/user/safeout',
    method: 'post',
    data: {
      uid
    }
  })
}

// 用户注册
export function regUser (cellphone, password, vcode) {
  return request({
    url: '/home/user/reg',
    method: 'post',
    data: {
      vcode,
      cellphone,
      password
    }
  })
}

// 用户手机号码是否注册过
export function isReg (username) {
  return request({
    url: 'home/user/isreg',
    method: 'post',
    data: {
      username
    }
  })
}

// 检测验证码是否正确
export function checkVCode (vcode) {
  return request({
    url: '/home/user/checkvcode',
    method: 'post',
    data: {
      vcode
    }
  })
}

// 获取会员信息
export function userData (uid) {
  return request({
    url: '/user/myinfo/userinfo/uid/' + uid,
    method: 'get',
  })
}

// 修改会员信息
export function updateUserData (options) {
  return request({
    url: '/user/myinfo/updateuser',
    method: 'post',
    data: {
      uid: options.uid,
      nickname: options.nickname,
      gender: options.gender,
      head: options.head
    }
  })
}

// 绑定手机和修改手机
export function updateCellphoneData (options) {
  return request({
    url: '/user/myinfo/updatecellphone',
    method: 'post',
    data: {
      uid: options.uid,
      cellphone: options.cellphone,
      vcode: options.vcode,
    }
  })
}

// 修改密码
export function modpwdData (options) {
  return request({
    url: '/user/myinfo/modpwd',
    method: 'post',
    data: {
      uid: options.uid,
      password: options.password,
    }
  })
}

// 头像上传
export function uploadHeaderData (headfile) {
  return request({
    url: '/user/myinfo/formdatahead',
    method: 'file',
    data: headfile
  })
}

// 会员登录认证接口   检测会员是否是登录状态
export function checkLogin (uid, authToken) {
  return request({
    url: '/home/user/safe',
    data: {
      uid: uid,
      auth_token: authToken
    },
    method: 'post',
  })
}


